<template>
  <div class="app-container">

    <el-row :gutter="24">

      <el-col :span="24" style="margin-bottom: 20px">

        <el-alert title="点击`开始考试`后将自动进入考试，请诚信考试！" type="error" style="margin-bottom: 10px" />

        <el-card class="pre-exam">

          <div><strong>考试名称：</strong>{{ detailData.paperName }}</div>
          <div><strong>考试时长：</strong>{{ detailData.examTotalSecond }}分钟</div>
          <div><strong>试卷总分：</strong>{{ detailData.paperScore }}分</div>
          <div><strong>及格分数：</strong>{{ detailData.passMark }}分</div>
          <div><strong>考试描述：</strong>{{ detailData.paperMark }}</div>
          <div><strong>开放类型：</strong> {{ detailData.isPublic === 0 ? '公开' : '受限' }}</div>

        </el-card>

      </el-col>

      <el-col :span="24">

        <el-button :loading="loading" type="primary" icon="el-icon-caret-right" @click="startExamPaper">
          开始考试
        </el-button>

        <el-button @click="handleBack">
          返回
        </el-button>

      </el-col>

    </el-row>
  </div>
</template>
  
<script>
import { queryPaperInfo, startExamPaper } from '@/api/onlineQuestion/paperQuestion'
export default {
  data() {
    return {
      detailData: {
        paperName: '',
        examTotalSecond: 0,
        paperScore: 0,
        passMark: '',
        paperMark: '',
        isPublic: 0
      },
      rules: {
        password: [
          { required: true, message: '考试密码不能为空！' }
        ]
      },

      loading: false
    }
  },

  created() {
    this.fetchData()
  },
  methods: {
    //试卷详情
    fetchData() {
      queryPaperInfo({
        waitPaperId: this.$route.params.waitPaperId
      }).then(res => {
        if (res.code === 200) {
          this.detailData = res.data.examPaper
        }
      })
    },

    //生成待答卷记录
    startExamPaper() {
      startExamPaper({
        waitPaperId: this.$route.params.waitPaperId
      }).then(res => {
        if (res.code === 200) {
          this.$router.push({ name: 'onlinePaper', params: { waitPaperId: this.$route.params.waitPaperId } })
        }

      })
    },

    handleBack() {
      this.$router.push({ name: 'WaitPaper' })
    },



  }
}
</script>
  
<style scoped>
.pre-exam div {

  line-height: 42px;
  color: #555555;
}
</style>
  
  